package com.dayuanit.dy14.enter.dy14enter1024.controller;

import com.dayuanit.dy14.enter.dy14enter1024.dto.ResponseDTO;
import com.dayuanit.dy14.enter.dy14enter1024.service.GroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class GroupController extends BaseController {

    @Autowired
    private GroupService groupService;

    @GetMapping(value = "/group/listTop10Group")
    public ResponseDTO listTop10Group() {
        return ResponseDTO.success(groupService.listTop10Group());
    }

    @GetMapping("/group/queryGroup")
    public ResponseDTO queryGroup(Byte status, @RequestParam(required = false) Integer groupId,
                                  @RequestParam(required = false, defaultValue = "1") Integer currentPage) {
        return ResponseDTO.success(groupService.queryGroup(status, groupId, currentPage));
    }

    @GetMapping(value = "/group/groupDetail/{groupId}")
    public ResponseDTO groupDetail(@PathVariable("groupId") int groupId) {
        return ResponseDTO.success(groupService.listGroupDetail(groupId));
    }

    @PostMapping(value = "/group/dismiss/{groupId}")
    public ResponseDTO dismissGroup(@PathVariable("groupId") int groupId) {
        groupService.dismiss(groupId);
        return ResponseDTO.success();
    }
}
